import { defineStore } from 'pinia'
import { doAccountLogin } from '../api/accout'
import storage from 'store'

export const useAccountStore = defineStore('account', {
  state: () => ({
    
  }),

  // 相当于 mutations
  actions: {
    doAccountLogin(params: any): Promise<any> {
      return new Promise((resolve, reject) => {
        doAccountLogin(params)
          .then((res:any) =>{
            if (res.code === 't_200') {
              const data = res.obj
              storage.set('token', data.token)
            }
            resolve(res)
          })
          .catch(err => reject(err))
      })
    }
  },
})